package com.promotion.front.service.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.promotion.front.dao.user.UserDao;
import com.promotion.front.entity.user.User;

@Component
@Transactional
public class UserManager {

	private UserDao userDao;

	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public void addUser(User entity) {
		userDao.addUser(entity);
	}
	
	public void deleteUser(long id) {
		userDao.deleteUser(id);
	}
	
	@Transactional(readOnly = true)
	public User getUser(Long id) {
		return userDao.getUserById(id);
	}

	@Transactional(readOnly = true)
	public User findUserByName(String name) {
		return userDao.getUserByName(name);
	}
	
	@Transactional(readOnly = true)
	public User findUserByMobile(String mobile) {
		return userDao.getUserByMobile(mobile);
	}

}
